//
//  CategorysCell.m
//  jipin
//
//  Created by lcb on 5/15/15.
//  Copyright (c) 2015 liuchengbin. All rights reserved.
//

#import "CategorysCell.h"
#import "UIButtonView.h"
@interface CategorysCell()
{
    
}

@property (nonatomic, strong) UIView *bgView;
@property (nonatomic, strong) UIButton *btnCat2;
@property (nonatomic, strong) UIButton *btnBrand;
@property (nonatomic, strong) UIButton *btnGood;
@property (nonatomic, strong) UIImageView *pimageView;
@property (nonatomic, strong) UIImageView *iconView;
@property (nonatomic, strong) UIImageView *imgBorderView1;
@property (nonatomic, strong) UIImageView *imgBorderView2;
@property (nonatomic, strong) UIImageView *imgBorderView3;
@property (nonatomic, strong) UIImageView *imgBorderView4;

@property(nonatomic,strong)UILabel *usernameLabel;
@property(nonatomic,strong)UILabel *timeLabel;
@property(nonatomic,strong)RTLabel *skuNameLabel;

@property (nonatomic, strong) UIButtonView *btnLikeV;
@property (nonatomic, strong) UIButtonView *btnReplyV;

@property(nonatomic,strong)UILabel *priceLabel;
@property(nonatomic,strong)UILabel *photoLabel;
@property(nonatomic,strong)UIImageView *lineView;
@end


@implementation CategorysCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        _bgView = [[UIView alloc] initWithFrame:CGRectZero];
        _bgView.backgroundColor =[UIColor clearColor];
        [self.contentView addSubview:_bgView];
        //
        _btnCat2 = [UIButton buttonWithType:UIButtonTypeCustom];
        [_btnCat2 setTitle:@"分类" forState:UIControlStateNormal];
        _btnCat2.backgroundColor = UIColorFromRGB(0xe74c3c);
        [_btnCat2 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        
        [_btnCat2 addTarget:self action:@selector(categoryAction:) forControlEvents:UIControlEventTouchUpInside];
        _btnCat2.titleLabel.font = FONT(14);
        _btnCat2.layer.cornerRadius = 3;//(值越大，角就越圆)
        _btnCat2.layer.masksToBounds = NO;
        
        _btnCat2.layer.rasterizationScale = [UIScreen mainScreen].scale;
        _btnCat2.layer.shouldRasterize = YES;
        _btnCat2.layer.shadowColor = [UIColor blackColor].CGColor;
        _btnCat2.layer.shadowOffset = SHADOW_OFFSET_OF_PAILIDE;
        
        _btnCat2.layer.shadowOpacity = 0.7;// 0.6;
        _btnCat2.layer.shadowRadius = 0.3;//阴影半径，默认3
        
        _btnBrand = [UIButton buttonWithType:UIButtonTypeCustom];
        [_btnBrand setTitle:@"品牌" forState:UIControlStateNormal];
        _btnBrand.backgroundColor = [UIColor colorWithRed:0.180 green:0.698 blue:0.427 alpha:1];//[UIColor whiteColor];
        [_btnBrand setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        
        [_btnBrand addTarget:self action:@selector(brandAction:) forControlEvents:UIControlEventTouchUpInside];
        _btnBrand.titleLabel.font = FONT(14);
        _btnBrand.layer.cornerRadius = 3;//(值越大，角就越圆)
        _btnBrand.layer.masksToBounds = NO;
        
        _btnBrand.layer.shadowColor = [UIColor blackColor].CGColor;
        _btnBrand.layer.shadowOffset = SHADOW_OFFSET_OF_PAILIDE;
        
        _btnBrand.layer.shadowOpacity = 0.7;// 0.6;
        _btnBrand.layer.shadowRadius = 0.3;//阴影半径，默认3
        
        _btnBrand.layer.rasterizationScale = [UIScreen mainScreen].scale;
        _btnBrand.layer.shouldRasterize = YES;
        
        
        _btnGood = [UIButton buttonWithType:UIButtonTypeCustom];
        [_btnGood setTitle:@"名称" forState:UIControlStateNormal];
        _btnGood.backgroundColor =[UIColor colorWithRed:0.176 green:0.463 blue:0.627 alpha:1];
        [_btnGood setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _btnGood.titleLabel.font = FONT(14);
        
        [_btnGood addTarget:self action:@selector(goodAction:) forControlEvents:UIControlEventTouchUpInside];
        UIEdgeInsets edge = _btnGood.contentEdgeInsets;
        edge.left += PHOTO_FRAME_WIDTH;
        edge.right+= PHOTO_FRAME_WIDTH;
        _btnGood.contentEdgeInsets = edge;
        _btnGood.layer.cornerRadius = 3;//(值越大，角就越圆)
        _btnGood.layer.masksToBounds = NO;
        _btnGood.layer.rasterizationScale = [UIScreen mainScreen].scale;
        _btnGood.layer.shouldRasterize = YES;
        _btnGood.layer.shadowColor = [UIColor blackColor].CGColor;
        _btnGood.layer.shadowOffset = SHADOW_OFFSET_OF_PAILIDE;
        _btnGood.layer.shadowOpacity = 0.6;// 0.6;
        _btnGood.layer.shadowRadius = 0.3;//阴影半径，默认3
        
        _imgBorderView4 =[[UIImageView alloc] initWithFrame:CGRectZero];
        _imgBorderView4.image =[UIImage imageNamed:@"border_04.png"];
        [_bgView addSubview:_imgBorderView4];
        
        [_bgView addSubview:_btnGood];
        //
        _imgBorderView3 =[[UIImageView alloc] initWithFrame:CGRectZero];
        _imgBorderView3.image =[UIImage imageNamed:@"border_03.png"];
        [_bgView addSubview:_imgBorderView3];
        
        [_bgView addSubview:_btnBrand];
        
        _imgBorderView2 =[[UIImageView alloc] initWithFrame:CGRectZero];
        _imgBorderView2.image =[UIImage imageNamed:@"border_02.png"];
        [_bgView addSubview:_imgBorderView2];
        
        [_bgView addSubview:_btnCat2];
        _imgBorderView1 =[[UIImageView alloc] initWithFrame:CGRectZero];
        _imgBorderView1.image =[UIImage imageNamed:@"border_01.png"];
        [_bgView addSubview:_imgBorderView1];
        
        //
        UITapGestureRecognizer* singleRecognizer= [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTapFrom)];
        _pimageView =[[UIImageView alloc] initWithFrame:CGRectZero];
        _pimageView.backgroundColor =UIColorFromRGB(0xffffff);
        _pimageView.userInteractionEnabled =YES;
        _pimageView.contentMode = UIViewContentModeScaleAspectFit;  
        [_pimageView addGestureRecognizer:singleRecognizer];
        [_bgView addSubview:_pimageView];
        singleRecognizer=nil;
        //
        _iconView =[[UIImageView alloc] initWithFrame:CGRectZero];
        _iconView.backgroundColor = PAILIDE_WHITE_FRAME_COLOR;
        _iconView.alpha = ALPHA_BACKVIEW_PAILIDE;
        _iconView.layer.borderWidth = 2;
        _iconView.layer.borderColor = [[UIColor whiteColor] CGColor];
        [_bgView addSubview:_iconView];
        
        _usernameLabel =[[UILabel alloc] initWithFrame:CGRectZero];
        _usernameLabel.backgroundColor = [UIColor clearColor];
        _usernameLabel.textColor = UIColorFromRGB(0x285790);
        _usernameLabel.textAlignment = NSTextAlignmentLeft;
        _usernameLabel.font = FONT(14);
        [_bgView addSubview:_usernameLabel];
        _timeLabel =[[UILabel alloc] initWithFrame:CGRectZero];
        _timeLabel.backgroundColor = [UIColor clearColor];
        _timeLabel.textColor = [UIColor lightGrayColor];
        _timeLabel.textAlignment = NSTextAlignmentRight;
        _timeLabel.font = FONT(14);
        [_bgView addSubview:_timeLabel];
        
         UITapGestureRecognizer* singleRecognizer1= [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTapFrom)];
        _skuNameLabel =[[RTLabel alloc] initWithFrame:CGRectMake(PHOTO_FRAME_WIDTH+PHOTO_TIME_PADDING,0, DEVICE_WIDTH-(PHOTO_FRAME_WIDTH+PHOTO_TIME_PADDING)*2,0)];
        _skuNameLabel.backgroundColor = [UIColor clearColor];
        _skuNameLabel.textColor = [UIColor darkGrayColor];
        _skuNameLabel.textAlignment = NSTextAlignmentLeft;
        _skuNameLabel.font = FONT(14);
        _skuNameLabel.lineSpacing = LSpacing;
        _skuNameLabel.userInteractionEnabled =YES;
        [_skuNameLabel addGestureRecognizer:singleRecognizer1];
        [_bgView addSubview:_skuNameLabel];
        singleRecognizer1=nil;
        //
        _btnLikeV = [[UIButtonView alloc] initWithFrame:CGRectZero];
        _btnLikeV.backgroundColor =  [UIColor clearColor];
        __weak typeof (self) wSelf = self;
        [_btnLikeV setCallBack:^(BEventType t, UIView *v, id data, id key) {
            [wSelf likeAction:nil];
        }];
        [_bgView addSubview:_btnLikeV];
        
        _btnReplyV = [[UIButtonView alloc] initWithFrame:CGRectZero];
        _btnReplyV.backgroundColor =  [UIColor clearColor];
        [_btnReplyV setCallBack:^(BEventType t, UIView *v, id data, id key) {
            [wSelf commentAction:nil];
        }];
        [_bgView addSubview:_btnReplyV];
        
        
        _priceLabel =[[UILabel alloc] initWithFrame:CGRectZero];
        _priceLabel.backgroundColor = [UIColor clearColor];
        _priceLabel.textColor = [UIColor darkGrayColor];
        _priceLabel.textAlignment = NSTextAlignmentRight;
        _priceLabel.font = FONT(12);
        [_bgView addSubview:_priceLabel];
        
        _photoLabel =[[UILabel alloc] initWithFrame:CGRectZero];
        _photoLabel.backgroundColor = [UIColor grayColor];
        _photoLabel.alpha=0.5;
        _photoLabel.textColor = [UIColor whiteColor];
        _photoLabel.textAlignment = NSTextAlignmentCenter;
        _photoLabel.font = FONT(14);
        _photoLabel.layer.cornerRadius = 3;//(值越大，角就越圆)
        _photoLabel.layer.masksToBounds = YES;
        [_bgView addSubview:_photoLabel];
        //
       
        _lineView =[[UIImageView alloc] initWithFrame:CGRectZero];
        _lineView.image =[UIImage imageNamed:@"line_xu.png"];
        [self.contentView addSubview:_lineView];
    }
    return self;
}
-(void)dealloc
{
    self.actionBlock=nil;
    self.data=nil;
    self.bgView=nil;
    self.btnCat2=nil;
    self.btnBrand=nil;
    self.btnGood=nil;
    self.pimageView=nil;
    self.iconView=nil;
    self.imgBorderView1=nil;
    self.imgBorderView2=nil;
    self.imgBorderView3=nil;
    self.imgBorderView4=nil;
    
    self.usernameLabel=nil;
    self.timeLabel=nil;
    self.skuNameLabel=nil;
    
    self.btnLikeV=nil;
    self.btnReplyV=nil;
    self.priceLabel=nil;
    self.photoLabel=nil;
//    DLog(@"%s", __PRETTY_FUNCTION__);
    
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    _bgView.frame =CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height);
    
}
- (void)drawRect:(CGRect)rect {
    [super drawRect:rect];
    self.lineView.frame=CGRectMake(0, self.bounds.size.height-1, DEVICE_WIDTH, 1);
}
/// 根据数据模型来显示内容
- (void)showInfo:(id)model other:(id)other key:(id)key indexPath:(NSIndexPath *)indexPath
{
    self.other =other;
    [self showInfo:model indexPath:indexPath];
}
- (void)showInfo:(id)model key:(id)key indexPath:(NSIndexPath *)indexPath
{
    self.key = key;
    [self showInfo:model indexPath:indexPath];
}
- (void)showInfo:(id)model indexPath:(NSIndexPath *)indexPath
{
    self.indexPath=indexPath;
    NSDictionary *dict =(NSDictionary*)model;
    self.data =model;
    NSString * strURL = [NSString stringWithFormat:@"%@", [dict objectForKey:@"largePicURL"]];
    float fTop = 0;
    fTop += PHOTO_FRAME_WIDTH ;
    fTop += PHOTO_TIME_PADDING ;
    float fBtnTop = PHOTO_TIME_PADDING;
    float fLeftOfBtn = PHOTO_TIME_PADDING;
    
    if(strURL == nil || [strURL isKindOfClass:[NSString class]] == NO)
    {
        strURL=nil;
        fLeftOfBtn += USER_ICON_WIDTH_IN_LIST;
    }
    
    NSString* strCat2 = [NSString stringWithFormat:@"%@", [dict objectForKey:@"cat2"]];
    if(strCat2 && [strCat2 isKindOfClass:[NSString class]] && [strCat2 length] > 0)
    {
        _btnCat2.hidden = NO;
        [_btnCat2 setTitle:strCat2 forState:UIControlStateNormal];
        CGSize size=[strCat2 sizeWithAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:13.0]}];
        float fCatWidth = ceil(size.width )+ PHOTO_FRAME_WIDTH*2 ;
        
        _btnCat2.frame =  CGRectMake(fLeftOfBtn, fBtnTop, fCatWidth, CAT_BUTTON_HEIGHT);
        
        fLeftOfBtn += fCatWidth - PHOTO_TIME_PADDING;
        
        if( CGAffineTransformIsIdentity(_btnCat2.transform))
        {
            float fRotation = ((float)(arc4random()%150)) /10000;
            if(((int)(fRotation * 10000)) % 2)
            {
                fRotation = -fRotation;
            }
            
            _btnCat2.transform = CGAffineTransformMakeRotation(M_PI * fRotation);
        }
    }
    else
    {
        _btnCat2.hidden = YES;
    }
    
    NSString* strBrand = [[NSString stringWithFormat:@"%@", [dict objectForKey:@"brand"]] replaceNullString];
    if(strBrand && [strBrand isKindOfClass:[NSString class]] && [strBrand length] > 0)
    {
        _btnBrand.hidden = NO;
        [_btnBrand setTitle:strBrand forState:UIControlStateNormal];
        
        // [cell.btnBrand sizeToFit];
        CGSize size=[strBrand sizeWithAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:13.0]}];
        
        float fBrandWidth = ceil(size.width )+ PHOTO_FRAME_WIDTH*2 ;
        
        
        _btnBrand.frame =  CGRectMake(fLeftOfBtn,
                                      fBtnTop,
                                      fBrandWidth,
                                      CAT_BUTTON_HEIGHT);
        
        fLeftOfBtn += fBrandWidth - PHOTO_TIME_PADDING;
        if( CGAffineTransformIsIdentity(_btnBrand.transform))
        {
            
            float fRotation = ((float)(arc4random()%150)) /10000;
            if(((int)(fRotation * 10000)) % 2)
            {
                fRotation = -fRotation;
            }
            _btnBrand.transform = CGAffineTransformMakeRotation(M_PI * fRotation);
        }
        
    }
    else
    {
        _btnBrand.hidden = YES;
    }
    
    
    
    
    NSString* strGood = [[NSString stringWithFormat:@"%@", [dict objectForKey:@"good"]] replaceNullString];
    if(strGood && [strGood isKindOfClass:[NSString class]] && [strGood length] > 0)
    {
        
        _btnGood.hidden = NO;
        [_btnGood setTitle:strGood forState:UIControlStateNormal];
        CGSize size=[strGood sizeWithAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:13.0]}];
        
        
        float fGoodWidth = ceil(size.width )+ PHOTO_FRAME_WIDTH*2 + 1;
        
        if( (fGoodWidth + fLeftOfBtn) > (DEVICE_WIDTH - PHOTO_TIME_PADDING) )
        {
            fGoodWidth = DEVICE_WIDTH - fLeftOfBtn - PHOTO_TIME_PADDING;
        }
        _btnGood.frame =  CGRectMake(fLeftOfBtn, fBtnTop, fGoodWidth, CAT_BUTTON_HEIGHT);
        
        if( CGAffineTransformIsIdentity(_btnGood.transform))
        {
            
            float fRotation = ((float)(arc4random()%50)) /10000;
            if(((int)(fRotation * 10000)) % 2)
            {
                fRotation = -fRotation;
            }
            
            if( fRotation > 0)
            {
                CGRect rc = _btnGood.frame;
                rc.origin.y += (int)fRotation%(int)PHOTO_TIME_PADDING;
                _btnGood.frame = rc;
            }
            _btnGood.transform = CGAffineTransformMakeRotation(M_PI * fRotation);
        }
    }
    else
    {
        _btnGood.hidden = YES;
    }
    
    fTop += TIME_HEIGHT;
    float fBackViewTop = 0;
    fTop += PHOTO_TIME_PADDING;
    fTop += PHOTO_TIME_PADDING;
    fBackViewTop = fTop + PHOTO_TIME_PADDING;
    
    _imgBorderView4.frame = CGRectMake(0, fBackViewTop - BOOK_FRAME, DEVICE_WIDTH, BOOK_FRAME);
    _imgBorderView3.frame = CGRectMake(0, fBackViewTop - BOOK_FRAME, DEVICE_WIDTH, BOOK_FRAME);
    _imgBorderView2.frame = CGRectMake(0, fBackViewTop - BOOK_FRAME, DEVICE_WIDTH, BOOK_FRAME);
    _imgBorderView1.frame = CGRectMake(0, fBackViewTop - BOOK_FRAME, DEVICE_WIDTH, BOOK_FRAME);
    
    
    fTop = _imgBorderView1.frame.origin.y+_imgBorderView1.frame.size.height+PHOTO_FRAME_WIDTH*2;
    
    _pimageView.frame = CGRectMake(PHOTO_FRAME_WIDTH*2, fTop, DEVICE_WIDTH-PHOTO_FRAME_WIDTH*4 ,DEVICE_WIDTH-PHOTO_FRAME_WIDTH*4);
    if (strURL!=nil&&strURL.length>0) {
        [_pimageView sd_setImageWithURL:[NSURL URLWithString:strURL] placeholderImage:[UIImage imageNamed:@"image.png"]];
    }
    
    
    id  picURL =[dict objectForKey:@"picURL"];
    if (picURL && [picURL isKindOfClass:[NSArray class]]) {
        int num = (int)[picURL count]+1;
        if (num>0) {
            _photoLabel.frame =CGRectMake(_pimageView.frame.origin.x+_pimageView.frame.size.width-30-PHOTO_FRAME_WIDTH/2, _pimageView.frame.origin.y+PHOTO_FRAME_WIDTH/2 ,  30, 20);
            _photoLabel.text =[NSString stringWithFormat:@"%d张",num];
        }
    }
    fTop = _pimageView.frame.origin.y+_pimageView.frame.size.height+PHOTO_FRAME_WIDTH;
    NSString *iconstr =[[NSString stringWithFormat:@"%@", [dict objectForKey:@"largeFace"]] replaceNullString];
    if(iconstr && iconstr.length>0&& ![iconstr isEqualToString:@"(null)"])
    {
       
        fTop = fTop - (43/2);
        _iconView.frame = CGRectMake(PHOTO_FRAME_WIDTH, fTop ,  43, 43);
        [_iconView sd_setImageWithURL:[NSURL URLWithString:iconstr] placeholderImage:[UIImage imageNamed:@"user_face.png"]];
        fTop=_iconView.frame.origin.y+_iconView.frame.size.height;
    }
    NSString *username =[[NSString stringWithFormat:@"%@", [dict objectForKey:@"nick_name"]] replaceNullString];
    if (username && username.length>0&& ![username isEqualToString:@"(null)"]) {
        if (_iconView.frame.origin.x>0) {
             _usernameLabel.frame = CGRectMake(_iconView.frame.origin.x+_iconView.frame.size.width+5,fTop-12, 120, 12);
        }
        else{
             _usernameLabel.frame = CGRectMake(PHOTO_FRAME_WIDTH,fTop, 120, 12);
        }
        _usernameLabel.text =username;
    }
    NSString *timestr =[[NSString stringWithFormat:@"%@", [dict objectForKey:@"upload_dateinfo"]] replaceNullString];
    if (timestr && timestr.length>0 && ![timestr isEqualToString:@"(null)"]) {
        if (_iconView.frame.origin.x>0) {
            _timeLabel.frame = CGRectMake(DEVICE_WIDTH-100-PHOTO_FRAME_WIDTH*2,fTop-12, 100, 12);
        }else{
              _timeLabel.frame = CGRectMake(DEVICE_WIDTH-100-PHOTO_FRAME_WIDTH*2,fTop, 100, 12);
        }
      
        _timeLabel.text =timestr;
    }
    
    if (_iconView.frame.origin.x<=0 && ((username.length>0&& ![username isEqualToString:@"(null)"])||(timestr.length>0&& ![timestr isEqualToString:@"(null)"]))) {
        fTop=fTop+12;
    }
    fTop = fTop+PHOTO_TIME_PADDING;
    
    //
    NSString *test =[[NSString stringWithFormat:@"%@", [dict objectForKey:@"text"]] replaceNullString];
    if (test.length==0) {
        test =[[NSString stringWithFormat:@"%@", [dict objectForKey:@"title"]] replaceNullString];
    }
    if (test.length>0) {
        test =[NSString stringWithFormat:@"\"%@\"",test];
    }
    
    [_skuNameLabel setText:test];
    CGSize optimumSize = [_skuNameLabel optimumSize];
    _skuNameLabel.frame = CGRectMake(PHOTO_FRAME_WIDTH+PHOTO_TIME_PADDING,fTop, DEVICE_WIDTH-(PHOTO_FRAME_WIDTH+PHOTO_TIME_PADDING)*2, optimumSize.height);
  
    //
    fTop = _skuNameLabel.frame.origin.y+_skuNameLabel.frame.size.height+PHOTO_FRAME_WIDTH;
    
     NSString *reply_cnt =[[NSString stringWithFormat:@"%@",[dict objectForKey:@"reply_cnt"]] replaceNullString];
    if (reply_cnt.length>0&&![reply_cnt isEqualToString:@"0"]) {
        [_btnReplyV setImage:[UIImage imageNamed:@"pinglun_icon.png"] name:reply_cnt];
        
    }else{
        reply_cnt =@"点评";
        [_btnReplyV setImage:[UIImage imageNamed:@"pinglun_icon.png"] name:@"点评"];
        
    }
    CGSize size1=[reply_cnt sizeWithAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:12.0]}];
    [_btnReplyV setFrame:CGRectMake(PAD_LEFT ,fTop, size1.width+25, MORE_BUTTON_HEIGHT)];
    
    NSString *like_cnt =[[NSString stringWithFormat:@"%@",[dict objectForKey:@"like_cnt"]] replaceNullString];
    if (like_cnt.length>0&&![like_cnt isEqualToString:@"0"]) {
        [_btnLikeV setImage:[UIImage imageNamed:@"like_icon.png"] name:like_cnt];
    }else
    {
        like_cnt =@"喜欢";
        [_btnLikeV setImage:[UIImage imageNamed:@"like_icon.png"] name:@"喜欢"];
    }
    CGSize size2=[like_cnt sizeWithAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:12.0]}];
    [_btnLikeV setFrame:CGRectMake(_btnReplyV.frame.origin.x+_btnReplyV.frame.size.width+PHOTO_FRAME_WIDTH ,fTop, size2.width+25, MORE_BUTTON_HEIGHT)];
    
    int isLike=[[NSString stringWithFormat:@"%@", [dict objectForKey:@"like"]] intValue];
    if (isLike) {
        [_btnLikeV setImage:[UIImage imageNamed:@"like_icon_selected.png"] name:like_cnt];
        
    }
   
    _priceLabel.frame = CGRectMake(DEVICE_WIDTH-100-PHOTO_FRAME_WIDTH*2,fTop, 100, MORE_BUTTON_HEIGHT);
    _priceLabel.text =[[NSString stringWithFormat:@"%@", [dict objectForKey:@"price_str"]] replaceNullString];
    [self layoutSubviews];
}


/// 返回Cell高度
+ (CGFloat)returnCellHeight:(id)model
{
    NSDictionary *dict =(NSDictionary*)model;
    NSString *test =[[NSString stringWithFormat:@"%@", [dict objectForKey:@"text"]] replaceNullString];
    if (test.length==0) {
        test =[[NSString stringWithFormat:@"%@", [dict objectForKey:@"title"]] replaceNullString];
    }
    if (test.length>0) {
        test =[NSString stringWithFormat:@"\"%@\"",test];
    }
    RTLabel *textLabel =[[RTLabel alloc] initWithFrame:CGRectMake(PHOTO_FRAME_WIDTH*2,0, DEVICE_WIDTH-PHOTO_FRAME_WIDTH*4,0)];
    textLabel.font = FONT(14);
    textLabel.lineSpacing = LSpacing;
    [textLabel setText:test];
    CGSize optimumSize1 = [textLabel optimumSize];
    textLabel=nil;
    
    int height = optimumSize1.height;
    NSString *iconstr =[[NSString stringWithFormat:@"%@", [dict objectForKey:@"largeFace"]] replaceNullString];
    NSString *username =[[NSString stringWithFormat:@"%@", [dict objectForKey:@"nick_name"]] replaceNullString];
    NSString *timestr =[[NSString stringWithFormat:@"%@", [dict objectForKey:@"upload_dateinfo"]] replaceNullString];
    if (iconstr && iconstr.length>0 && ![iconstr isEqualToString:@"(null)"]) {
          return DEVICE_WIDTH-PHOTO_FRAME_WIDTH*4+height+MORE_BUTTON_HEIGHT+PHOTO_FRAME_WIDTH*4+72;
    }else if( username.length==0 && timestr.length==0){
        return DEVICE_WIDTH-PHOTO_FRAME_WIDTH*4+height+MORE_BUTTON_HEIGHT+PHOTO_FRAME_WIDTH*4+50;
    }else
    {
        return DEVICE_WIDTH-PHOTO_FRAME_WIDTH*4+height+MORE_BUTTON_HEIGHT+PHOTO_FRAME_WIDTH*4+62;
    }
  
}
-(void)setCallBack:(void(^)(BEventType,UIView*,id,id,NSIndexPath *))callback
{
    self.actionBlock=callback;
}
-(void)categoryAction:(id)sender
{
    if (self.actionBlock) {
        self.actionBlock(BEventType_category,sender,self.data,self.key,self.indexPath);
    }
}
-(void)brandAction:(id)sender
{
    if (self.actionBlock) {
        self.actionBlock(BEventType_brand,sender,self.data,self.key,self.indexPath);
    }
}
-(void)goodAction:(id)sender
{
    if (self.actionBlock) {
        self.actionBlock(BEventType_good,sender,self.data,self.key,self.indexPath);
    }
}
-(void)likeAction:(id)sender
{
    if (self.actionBlock) {
        self.actionBlock(BEventType_like,sender,self.data,self.key,self.indexPath);
    }
}
-(void)commentAction:(id)sender
{
    if (self.actionBlock) {
        self.actionBlock(BEventType_comment,sender,self.data,self.key,self.indexPath);
    }
}
-(void)handleSingleTapFrom
{
    if (self.actionBlock) {
        self.actionBlock(BEventType_good,nil,self.data,self.key,self.indexPath);
    }
}

@end
